home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / sun / volume2 / calentool / patch5d < prev    next >
Encoding:
Internet Message Format  |  1990-02-04  |  53.7 KB

  1. Subject:  v02i006:  calentool - patch level 5, Part 4/4
  2. Newsgroups: comp.sources.sun
  3. Approved: mcgrew@aramis.rutgers.edu
  4.  
  5. Submitted-by: Bill Randle <billr@saab.cna.tek.com>
  6. Posting-number: Volume 2, Issue 6
  7. Archive-name: calentool/patch5d
  8.  
  9.  
  10.  
  11. #! /bin/sh
  12. # This is a shell archive.  Remove anything before this line, then unpack
  13. # it by saving it into a file and typing "sh file".  To overwrite existing
  14. # files, type "sh file -c".  You can also feed this as standard input via
  15. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  16. # will see the following message at the end:
  17. #        "End of archive 4 (of 4)."
  18. # Contents:  patches05d
  19. # Wrapped by billr@saab on Tue Dec 19 11:47:41 1989
  20. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  21. if test -f 'patches05d' -a "${1}" != "-c" ; then 
  22.   echo shar: Will not clobber existing file \"'patches05d'\"
  23. else
  24. echo shar: Extracting \"'patches05d'\" \(51460 characters\)
  25. sed "s/^X//" >'patches05d' <<'END_OF_FILE'
  26. X*** /tmp/,RCSt1a02457    Tue Dec 19 11:34:42 1989
  27. X--- utils.c    Tue Dec 19 11:34:15 1989
  28. X***************
  29. X*** 1,5
  30. X  /*
  31. X!  * $Header: utils.c,v 2.3 89/07/19 20:31:40 billr Exp $
  32. X   */
  33. X  /*
  34. X   * utils.c
  35. X
  36. X--- 1,5 -----
  37. X  /*
  38. X!  * $Header: utils.c,v 2.5 89/12/19 11:33:44 billr Exp $
  39. X   */
  40. X  /*
  41. X   * utils.c
  42. X***************
  43. X*** 22,27
  44. X   * Permission is hereby granted to use and modify the modifications in source
  45. X   * or binary form as long as they are not sold for profit and this copyright
  46. X   * notice remains intact.
  47. X   */
  48. X  /********************************************
  49. X   *                        *
  50. X
  51. X--- 22,29 -----
  52. X   * Permission is hereby granted to use and modify the modifications in source
  53. X   * or binary form as long as they are not sold for profit and this copyright
  54. X   * notice remains intact.
  55. X+  * Modified parse_date to allow +nnn and -nnn syntax for dates relative to the
  56. X+  * current date.  Peter Marshall <peter.marshall@uwo.ca>. 1989-09-19.
  57. X   */
  58. X  /********************************************
  59. X   *                        *
  60. X***************
  61. X*** 33,38
  62. X  
  63. X  #include "ct.h"
  64. X  #include <stdio.h>
  65. X  #include <suntool/sunview.h>
  66. X  #include <suntool/canvas.h>
  67. X  #include <ctype.h>
  68. X
  69. X--- 35,41 -----
  70. X  
  71. X  #include "ct.h"
  72. X  #include <stdio.h>
  73. X+ #ifndef NOTOOL
  74. X  #include <suntool/sunview.h>
  75. X  #include <suntool/canvas.h>
  76. X  #endif  /* NOTOOL */
  77. X***************
  78. X*** 35,40
  79. X  #include <stdio.h>
  80. X  #include <suntool/sunview.h>
  81. X  #include <suntool/canvas.h>
  82. X  #include <ctype.h>
  83. X  #include <sys/types.h>
  84. X  #include <sys/file.h>
  85. X
  86. X--- 38,44 -----
  87. X  #ifndef NOTOOL
  88. X  #include <suntool/sunview.h>
  89. X  #include <suntool/canvas.h>
  90. X+ #endif  /* NOTOOL */
  91. X  #include <ctype.h>
  92. X  #include <sys/types.h>
  93. X  #include <sys/time.h>
  94. X***************
  95. X*** 37,42
  96. X  #include <suntool/canvas.h>
  97. X  #include <ctype.h>
  98. X  #include <sys/types.h>
  99. X  #include <sys/file.h>
  100. X  #include <sys/stat.h>
  101. X  #include <sys/errno.h>
  102. X
  103. X--- 41,47 -----
  104. X  #endif  /* NOTOOL */
  105. X  #include <ctype.h>
  106. X  #include <sys/types.h>
  107. X+ #include <sys/time.h>
  108. X  #include <sys/file.h>
  109. X  #include <sys/stat.h>
  110. X  #include <sys/errno.h>
  111. X***************
  112. X*** 54,60
  113. X  extern int one_based, version2, new_entry;
  114. X  extern int findex;
  115. X  extern struct appt_entry future[];
  116. X- extern char todays_date[];
  117. X  extern char apts_dir[], lib_dir[];
  118. X  extern char printer[];
  119. X  extern int include_old, save_old;
  120. X
  121. X--- 59,64 -----
  122. X  extern int one_based, version2, new_entry;
  123. X  extern int findex;
  124. X  extern struct appt_entry future[];
  125. X  extern char apts_dir[], lib_dir[];
  126. X  extern int include_old, save_old, expire_days;
  127. X  #ifndef NOTOOL
  128. X***************
  129. X*** 56,61
  130. X  extern struct appt_entry future[];
  131. X  extern char todays_date[];
  132. X  extern char apts_dir[], lib_dir[];
  133. X  extern char printer[];
  134. X  extern int include_old, save_old;
  135. X  extern Frame frame;
  136. X
  137. X--- 60,67 -----
  138. X  extern int findex;
  139. X  extern struct appt_entry future[];
  140. X  extern char apts_dir[], lib_dir[];
  141. X+ extern int include_old, save_old, expire_days;
  142. X+ #ifndef NOTOOL
  143. X  extern char printer[];
  144. X  extern Frame frame;
  145. X  extern Canvas canvas;
  146. X***************
  147. X*** 57,63
  148. X  extern char todays_date[];
  149. X  extern char apts_dir[], lib_dir[];
  150. X  extern char printer[];
  151. X- extern int include_old, save_old;
  152. X  extern Frame frame;
  153. X  extern Canvas canvas;
  154. X  extern Pixwin *main_pixwin;
  155. X
  156. X--- 63,68 -----
  157. X  extern int include_old, save_old, expire_days;
  158. X  #ifndef NOTOOL
  159. X  extern char printer[];
  160. X  extern Frame frame;
  161. X  extern Canvas canvas;
  162. X  extern Pixwin *main_pixwin;
  163. X***************
  164. X*** 65,70
  165. X  extern Pixfont *font, *sfont;
  166. X  extern Frame prompt_frame;
  167. X  extern int update_interval;
  168. X  extern int errno;
  169. X  
  170. X  char inbuf[512], strbuf[256], errbuf[64];
  171. X
  172. X--- 70,77 -----
  173. X  extern Pixfont *font, *sfont;
  174. X  extern Frame prompt_frame;
  175. X  extern int update_interval;
  176. X+ extern int monday_first, hour24, day_first;
  177. X+ #endif  /* NOTOOL */
  178. X  extern int errno;
  179. X  
  180. X  char inbuf[512], strbuf[256], errbuf[128];
  181. X***************
  182. X*** 67,75
  183. X  extern int update_interval;
  184. X  extern int errno;
  185. X  
  186. X! char inbuf[512], strbuf[256], errbuf[64];
  187. X! char todays_date[32];
  188. X! static int including;
  189. X  static int log_to_console;
  190. X  char *daynames[] = {"Sunday","Monday","Tuesday","Wednesday",
  191. X                 "Thursday","Friday","Saturday"};
  192. X
  193. X--- 74,82 -----
  194. X  #endif  /* NOTOOL */
  195. X  extern int errno;
  196. X  
  197. X! char inbuf[512], strbuf[256], errbuf[128];
  198. X! char clockstr[32];
  199. X! static int include_level = 0;
  200. X  static int log_to_console;
  201. X  char *daynames[] = {"Sunday","Monday","Tuesday","Wednesday",
  202. X                 "Thursday","Friday","Saturday"};
  203. X***************
  204. X*** 76,81
  205. X  char *monthnames[] = {"January","February","March","April",
  206. X                   "May","June","July","August",
  207. X                   "September","October","November","December"};
  208. X  char *dayname[7] = {"SU", "MO", "TU", "WE", "TH", "FR", "SA"};
  209. X  char rasfile[] = "/usr/tmp/calentool.ras";
  210. X  char psfile[] = "/usr/tmp/calentool.ps";
  211. X
  212. X--- 83,91 -----
  213. X  char *monthnames[] = {"January","February","March","April",
  214. X                   "May","June","July","August",
  215. X                   "September","October","November","December"};
  216. X+ char *smonthnames[] = {"Jan","Feb","Mar","Apr",
  217. X+                  "May","Jun","Jul","Aug",
  218. X+                  "Sep","Oct","Nov","Dec"};
  219. X  char *dayname[7] = {"SU", "MO", "TU", "WE", "TH", "FR", "SA"};
  220. X  char rasfile[] = "/usr/tmp/calentool.ras";
  221. X  char psfile[] = "/usr/tmp/calentool.ps";
  222. X***************
  223. X*** 91,96
  224. X  {
  225. X      struct tm *tm;
  226. X      struct timeval tv;
  227. X  
  228. X      gettimeofday(&tv, 0);
  229. X      tm = localtime(&tv.tv_sec);
  230. X
  231. X--- 101,107 -----
  232. X  {
  233. X      struct tm *tm;
  234. X      struct timeval tv;
  235. X+     char timstr[16];
  236. X  
  237. X      gettimeofday(&tv, 0);
  238. X      tm = localtime(&tv.tv_sec);
  239. X***************
  240. X*** 97,103
  241. X  
  242. X      today = *tm;
  243. X  
  244. X!     strcpy(todays_date, asctime(tm));
  245. X      if (update_interval >= 60)
  246. X          /* overwrite seconds field with year */
  247. X          sprintf(&todays_date[16], " %d", today.tm_year+1900);
  248. X
  249. X--- 108,120 -----
  250. X  
  251. X      today = *tm;
  252. X  
  253. X! #ifndef CALENCHECK
  254. X!     if (day_first)
  255. X!         sprintf(clockstr, "%3.3s %d %s %d, ", daynames[today.tm_wday],
  256. X!             today.tm_mday, smonthnames[today.tm_mon], today.tm_year+1900);
  257. X!     else
  258. X!         sprintf(clockstr, "%3.3s %s %d %d, ", daynames[today.tm_wday],
  259. X!             smonthnames[today.tm_mon], today.tm_mday, today.tm_year+1900);
  260. X      if (update_interval >= 60)
  261. X          sprintf(timstr, "%02d:%02d", today.tm_hour, today.tm_min);
  262. X      else
  263. X***************
  264. X*** 99,106
  265. X  
  266. X      strcpy(todays_date, asctime(tm));
  267. X      if (update_interval >= 60)
  268. X!         /* overwrite seconds field with year */
  269. X!         sprintf(&todays_date[16], " %d", today.tm_year+1900);
  270. X      else
  271. X          /* just delete trailing \n */
  272. X          todays_date[strlen(todays_date)-1] = '\0';
  273. X
  274. X--- 116,122 -----
  275. X          sprintf(clockstr, "%3.3s %s %d %d, ", daynames[today.tm_wday],
  276. X              smonthnames[today.tm_mon], today.tm_mday, today.tm_year+1900);
  277. X      if (update_interval >= 60)
  278. X!         sprintf(timstr, "%02d:%02d", today.tm_hour, today.tm_min);
  279. X      else
  280. X          sprintf(timstr, "%02d:%02d:%02d", today.tm_hour, today.tm_min, today.tm_sec);
  281. X      if (!hour24) {
  282. X***************
  283. X*** 102,109
  284. X          /* overwrite seconds field with year */
  285. X          sprintf(&todays_date[16], " %d", today.tm_year+1900);
  286. X      else
  287. X!         /* just delete trailing \n */
  288. X!         todays_date[strlen(todays_date)-1] = '\0';
  289. X  }
  290. X  
  291. X  /*
  292. X
  293. X--- 118,140 -----
  294. X      if (update_interval >= 60)
  295. X          sprintf(timstr, "%02d:%02d", today.tm_hour, today.tm_min);
  296. X      else
  297. X!         sprintf(timstr, "%02d:%02d:%02d", today.tm_hour, today.tm_min, today.tm_sec);
  298. X!     if (!hour24) {
  299. X!         /* display am/pm for 12-hour time */
  300. X!         if (today.tm_hour > 12) {
  301. X!             strcat(timstr, "pm");
  302. X!             timstr[0] = ((today.tm_hour - 12) / 10) + '0';
  303. X!             timstr[1] = ((today.tm_hour - 12) % 10) + '0';
  304. X!         } else if (today.tm_hour == 12) {
  305. X!             strcat(timstr, "pm");
  306. X!         } else {
  307. X!             strcat(timstr, "am");
  308. X!         }
  309. X!         if (timstr[0] == '0')
  310. X!             timstr[0] = ' ';
  311. X!     }
  312. X!     strcat(clockstr, timstr);
  313. X! #endif  /* CALENCHECK */
  314. X  }
  315. X  
  316. X  /*
  317. X***************
  318. X*** 140,169
  319. X              current.tm_year++;
  320. X          }
  321. X      }
  322. X!     current.tm_yday = current.tm_mday - 1;
  323. X!     for (month = 0; month < current.tm_mon; month++) {
  324. X!         current.tm_yday += monthlength(month);
  325. X!     }
  326. X!     if ((current.tm_year < today.tm_year)
  327. X!         || ((current.tm_year == today.tm_year)
  328. X!         && (current.tm_yday < today.tm_yday))) {
  329. X!         from = current;
  330. X!         to = today;
  331. X!     } else {
  332. X!         from = today;
  333. X!         to = current;
  334. X!     }
  335. X!     if (from.tm_year != to.tm_year) {
  336. X!         for (totdays = 0; from.tm_year < to.tm_year; from.tm_year++)
  337. X!             totdays += dysize(from.tm_year + 1900);
  338. X!     }
  339. X!     totdays += to.tm_yday - from.tm_yday;
  340. X!     if ((current.tm_year < today.tm_year)
  341. X!         || ((current.tm_year == today.tm_year)
  342. X!         && (current.tm_yday < today.tm_yday)))
  343. X!         totdays = -totdays;
  344. X!     current.tm_wday =
  345. X!         ((totdays % 7) + 7 + today.tm_wday) % 7;
  346. X  }
  347. X  
  348. X  /*
  349. X
  350. X--- 171,178 -----
  351. X              current.tm_year++;
  352. X          }
  353. X      }
  354. X!     current.tm_yday = day_of_year((double)current.tm_mday, current.tm_mon+1, current.tm_year+1900);
  355. X!     current.tm_wday = get_day_of_week((double)current.tm_mday, current.tm_mon+1, current.tm_year+1900);
  356. X  }
  357. X  
  358. X  /*
  359. X***************
  360. X*** 188,194
  361. X  {
  362. X      static int    monthlengths[] = {31,28,31,30,31,30,31,31,30,31,30,31};
  363. X  
  364. X!     if (month == FEB && (dysize(current.tm_year + 1900) == 366))
  365. X          return(29);
  366. X      else
  367. X          return(monthlengths[month]);
  368. X
  369. X--- 197,203 -----
  370. X  {
  371. X      static int    monthlengths[] = {31,28,31,30,31,30,31,31,30,31,30,31};
  372. X  
  373. X!     if (month == FEB && (length_of_year(current.tm_year + 1900) == 366))
  374. X          return(29);
  375. X      else
  376. X          return(monthlengths[month]);
  377. X***************
  378. X*** 194,199
  379. X          return(monthlengths[month]);
  380. X  }
  381. X  
  382. X  /*
  383. X   *
  384. X   * Append data from active timeslots to end of "tmp.appointments"
  385. X
  386. X--- 203,209 -----
  387. X          return(monthlengths[month]);
  388. X  }
  389. X  
  390. X+ #ifndef CALENCHECK
  391. X  /*
  392. X   *
  393. X   * Append data from active timeslots to end of "tmp.appointments"
  394. X***************
  395. X*** 256,261
  396. X          return(1);
  397. X      xrename(tmpapts_pathname, apts_pathname);
  398. X  }
  399. X  
  400. X  /*
  401. X   * get entry from appointments file
  402. X
  403. X--- 266,272 -----
  404. X          return(1);
  405. X      xrename(tmpapts_pathname, apts_pathname);
  406. X  }
  407. X+ #endif  /* CALENCHECK */
  408. X  
  409. X  /*
  410. X   * get entry from appointments file
  411. X***************
  412. X*** 260,266
  413. X  /*
  414. X   * get entry from appointments file
  415. X   */
  416. X! get_aentry(apts_file, appt)
  417. X  FILE *apts_file;
  418. X  struct appt_entry *appt;
  419. X  {
  420. X
  421. X--- 271,277 -----
  422. X  /*
  423. X   * get entry from appointments file
  424. X   */
  425. X! get_aentry(apts_file, appt, noInclude)
  426. X  FILE *apts_file;
  427. X  struct appt_entry *appt;
  428. X  int noInclude;
  429. X***************
  430. X*** 263,268
  431. X  get_aentry(apts_file, appt)
  432. X  FILE *apts_file;
  433. X  struct appt_entry *appt;
  434. X  {
  435. X      char *ptr, *str;
  436. X      char *fgets(), *index();
  437. X
  438. X--- 274,280 -----
  439. X  get_aentry(apts_file, appt, noInclude)
  440. X  FILE *apts_file;
  441. X  struct appt_entry *appt;
  442. X+ int noInclude;
  443. X  {
  444. X      char *ptr, *str;
  445. X      char *fgets(), *index();
  446. X***************
  447. X*** 267,273
  448. X      char *ptr, *str;
  449. X      char *fgets(), *index();
  450. X      char *incl_ptr, incl_buf[128], wday[3];
  451. X!     int i, lib;
  452. X      struct stat sbuf;
  453. X      static FILE *include;
  454. X  
  455. X
  456. X--- 279,285 -----
  457. X      char *ptr, *str;
  458. X      char *fgets(), *index();
  459. X      char *incl_ptr, incl_buf[128], wday[3];
  460. X!     int i, lib, parse_options, nodata = 1;
  461. X      struct stat sbuf;
  462. X      static FILE *include[MAX_INCLUDE_NESTING];
  463. X  
  464. X***************
  465. X*** 269,275
  466. X      char *incl_ptr, incl_buf[128], wday[3];
  467. X      int i, lib;
  468. X      struct stat sbuf;
  469. X!     static FILE *include;
  470. X  
  471. X      appt->flags = appt->repeat = appt->lookahead = 0;
  472. X      appt->sindex = 0;
  473. X
  474. X--- 281,287 -----
  475. X      char *incl_ptr, incl_buf[128], wday[3];
  476. X      int i, lib, parse_options, nodata = 1;
  477. X      struct stat sbuf;
  478. X!     static FILE *include[MAX_INCLUDE_NESTING];
  479. X  
  480. X      appt->flags = appt->repeat = appt->lookahead = 0;
  481. X      appt->sindex = 0;
  482. X***************
  483. X*** 273,278
  484. X  
  485. X      appt->flags = appt->repeat = appt->lookahead = 0;
  486. X      appt->sindex = 0;
  487. X      appt->next = NULL;
  488. X      if (including) {
  489. X          if (fgets(inbuf, 512, include) == NULL) {
  490. X
  491. X--- 285,291 -----
  492. X  
  493. X      appt->flags = appt->repeat = appt->lookahead = 0;
  494. X      appt->sindex = 0;
  495. X+     appt->runlength = 0;
  496. X      appt->next = NULL;
  497. X      /* If noInclude is set then don't follow include files, i.e.
  498. X       * treat #include directives as comments. This is useful for
  499. X***************
  500. X*** 274,286
  501. X      appt->flags = appt->repeat = appt->lookahead = 0;
  502. X      appt->sindex = 0;
  503. X      appt->next = NULL;
  504. X!     if (including) {
  505. X!         if (fgets(inbuf, 512, include) == NULL) {
  506. X!             /* end of include file - get next entry
  507. X!              * from main file
  508. X!              */
  509. X!             including = 0;
  510. X!             fclose(include);
  511. X              if (fgets(inbuf, 512, apts_file) == NULL)
  512. X                  return(EOF);
  513. X          } else {
  514. X
  515. X--- 287,310 -----
  516. X      appt->sindex = 0;
  517. X      appt->runlength = 0;
  518. X      appt->next = NULL;
  519. X!     /* If noInclude is set then don't follow include files, i.e.
  520. X!      * treat #include directives as comments. This is useful for
  521. X!      * copying the appts file.
  522. X!      */
  523. X!     while (nodata) {
  524. X!         if (include_level) {
  525. X!             if (fgets(inbuf, 512, include[include_level-1]) == NULL) {
  526. X!                 /* end of include file - get next entry
  527. X!                  * from previous level of nesting
  528. X!                  */
  529. X!                 fclose(include[include_level-1]);
  530. X!                 include_level--;
  531. X!             } else {
  532. X!                 /* don't modify stuff from include files */
  533. X!                 appt->flags |= READONLY;
  534. X!                 nodata = 0;    /* still data in file */
  535. X!             }
  536. X!         } else {
  537. X              if (fgets(inbuf, 512, apts_file) == NULL)
  538. X                  return(EOF);
  539. X              else
  540. X***************
  541. X*** 283,292
  542. X              fclose(include);
  543. X              if (fgets(inbuf, 512, apts_file) == NULL)
  544. X                  return(EOF);
  545. X!         } else {
  546. X!             including = 2;
  547. X!             /* don't modify stuff from include files */
  548. X!             appt->flags |= READONLY;
  549. X          }
  550. X      } else
  551. X          if (fgets(inbuf, 512, apts_file) == NULL)
  552. X
  553. X--- 307,314 -----
  554. X          } else {
  555. X              if (fgets(inbuf, 512, apts_file) == NULL)
  556. X                  return(EOF);
  557. X!             else
  558. X!                 nodata = 0;    /* still data in file */
  559. X          }
  560. X      }
  561. X      ptr = inbuf;
  562. X***************
  563. X*** 288,296
  564. X              /* don't modify stuff from include files */
  565. X              appt->flags |= READONLY;
  566. X          }
  567. X!     } else
  568. X!         if (fgets(inbuf, 512, apts_file) == NULL)
  569. X!             return(EOF);
  570. X      ptr = inbuf;
  571. X      if (*ptr == '#') {
  572. X          if (!strcmp(inbuf, HEADER) && !including) {
  573. X
  574. X--- 310,316 -----
  575. X              else
  576. X                  nodata = 0;    /* still data in file */
  577. X          }
  578. X!     }
  579. X      ptr = inbuf;
  580. X      if (noInclude && *ptr == '#') {
  581. X          appt->flags |= A_COMMENT;
  582. X***************
  583. X*** 292,297
  584. X          if (fgets(inbuf, 512, apts_file) == NULL)
  585. X              return(EOF);
  586. X      ptr = inbuf;
  587. X      if (*ptr == '#') {
  588. X          if (!strcmp(inbuf, HEADER) && !including) {
  589. X              /* first line in file read */
  590. X
  591. X--- 312,321 -----
  592. X          }
  593. X      }
  594. X      ptr = inbuf;
  595. X+     if (noInclude && *ptr == '#') {
  596. X+         appt->flags |= A_COMMENT;
  597. X+         return(0);
  598. X+     }
  599. X      if (*ptr == '#') {
  600. X          if (!strcmp(inbuf, HEADER) && !include_level) {
  601. X              /* first line in base file read */
  602. X***************
  603. X*** 293,300
  604. X              return(EOF);
  605. X      ptr = inbuf;
  606. X      if (*ptr == '#') {
  607. X!         if (!strcmp(inbuf, HEADER) && !including) {
  608. X!             /* first line in file read */
  609. X              if (include_old && (First.tm_year < today.tm_year)) {
  610. X                  /* read in old include file (if it exists) */
  611. X                  /* prepend directory info */
  612. X
  613. X--- 317,324 -----
  614. X          return(0);
  615. X      }
  616. X      if (*ptr == '#') {
  617. X!         if (!strcmp(inbuf, HEADER) && !include_level) {
  618. X!             /* first line in base file read */
  619. X              if (include_old && (First.tm_year < today.tm_year)) {
  620. X                  /* read in old include file (if it exists) */
  621. X                  /* prepend directory info */
  622. X***************
  623. X*** 301,310
  624. X                  sprintf(incl_buf, "%s/.appointments.%02d",
  625. X                      apts_dir, First.tm_year);
  626. X                  if (!stat(incl_buf, &sbuf)) {
  627. X!                     if ((include = fopen(incl_buf, "r")) == NULL)
  628. X!                         err_rpt("can't open include file (ignored)", NON_FATAL);
  629. X!                     else
  630. X!                         including = 1;
  631. X                  }
  632. X              }
  633. X          } else if (!strncmp(inbuf, "#include", 8)) {
  634. X
  635. X--- 325,337 -----
  636. X                  sprintf(incl_buf, "%s/.appointments.%02d",
  637. X                      apts_dir, First.tm_year);
  638. X                  if (!stat(incl_buf, &sbuf)) {
  639. X!                     if ((include[include_level] = fopen(incl_buf, "r")) == NULL) {
  640. X!                         strcpy(errbuf, "can't open include file <");
  641. X!                         strcat(errbuf, incl_buf);
  642. X!                         strcat(errbuf, "> (ignored)");
  643. X!                         err_rpt(errbuf, NON_FATAL);
  644. X!                     } else
  645. X!                         include_level++;
  646. X                  }
  647. X              }
  648. X          } else if (!strncmp(inbuf, "#include", 8)) {
  649. X***************
  650. X*** 309,316
  651. X              }
  652. X          } else if (!strncmp(inbuf, "#include", 8)) {
  653. X              /* include file */
  654. X!             if (including)
  655. X!                 err_rpt("include files may not be nested", FATAL);
  656. X              incl_ptr = strbuf;
  657. X              if ((ptr = index(inbuf, '"')) == NULL)
  658. X  
  659. X
  660. X--- 336,346 -----
  661. X              }
  662. X          } else if (!strncmp(inbuf, "#include", 8)) {
  663. X              /* include file */
  664. X!             if (include_level > MAX_INCLUDE_NESTING) {
  665. X!                 err_rpt("include files nested too deep (ignored)", NON_FATAL);
  666. X!                 appt->flags |= A_COMMENT;
  667. X!                 return(0);
  668. X!             }
  669. X              incl_ptr = strbuf;
  670. X              if ((ptr = index(inbuf, '"')) == NULL)
  671. X  
  672. X***************
  673. X*** 316,321
  674. X  
  675. X                  if ((ptr = index(inbuf, '<')) == NULL) {
  676. X                      err_rpt("missing '\"' or '<' in include file spec", NON_FATAL);
  677. X                      return(0);
  678. X                  } else {
  679. X                      lib = 1;
  680. X
  681. X--- 346,352 -----
  682. X  
  683. X                  if ((ptr = index(inbuf, '<')) == NULL) {
  684. X                      err_rpt("missing '\"' or '<' in include file spec", NON_FATAL);
  685. X+                     appt->flags |= A_COMMENT;
  686. X                      return(0);
  687. X                  } else {
  688. X                      lib = 1;
  689. X***************
  690. X*** 327,332
  691. X                  *incl_ptr++ = *ptr++;
  692. X              if (! *ptr) {
  693. X                  err_rpt("missing '\"' or '>' in include file spec", NON_FATAL);
  694. X                  return(0);
  695. X              }
  696. X              *incl_ptr = '\0';
  697. X
  698. X--- 358,364 -----
  699. X                  *incl_ptr++ = *ptr++;
  700. X              if (! *ptr) {
  701. X                  err_rpt("missing '\"' or '>' in include file spec", NON_FATAL);
  702. X+                 appt->flags |= A_COMMENT;
  703. X                  return(0);
  704. X              }
  705. X              *incl_ptr = '\0';
  706. X***************
  707. X*** 339,348
  708. X                      sprintf(incl_buf, "%s/%s", lib_dir, strbuf);
  709. X                  else
  710. X                      sprintf(incl_buf, "%s/%s", apts_dir, strbuf);
  711. X!             if ((include = fopen(incl_buf, "r")) == NULL)
  712. X!                 err_rpt("can't open include file (ignored)", NON_FATAL);
  713. X!             else 
  714. X!                 including = 1;
  715. X          }
  716. X          appt->flags |= A_COMMENT;
  717. X          return(0);
  718. X
  719. X--- 371,383 -----
  720. X                      sprintf(incl_buf, "%s/%s", lib_dir, strbuf);
  721. X                  else
  722. X                      sprintf(incl_buf, "%s/%s", apts_dir, strbuf);
  723. X!             if ((include[include_level] = fopen(incl_buf, "r")) == NULL) {
  724. X!                 strcpy(errbuf, "can't open include file <");
  725. X!                 strcat(errbuf, incl_buf);
  726. X!                 strcat(errbuf, "> (ignored)");
  727. X!                 err_rpt(errbuf, NON_FATAL);
  728. X!             } else 
  729. X!                 include_level++;
  730. X          }
  731. X          appt->flags |= A_COMMENT;
  732. X          return(0);
  733. X***************
  734. X*** 367,373
  735. X          }
  736. X          /* sanity check */
  737. X          if (appt->year < 0) {
  738. X!             err_rpt("illegal year value (ignored)", NON_FATAL);
  739. X              return(1);
  740. X          }
  741. X      }
  742. X
  743. X--- 402,409 -----
  744. X          }
  745. X          /* sanity check */
  746. X          if (appt->year < 0) {
  747. X!             sprintf(errbuf, "illegal year value [%d] (ignored)", appt->year);
  748. X!             err_rpt(errbuf, NON_FATAL);
  749. X              return(1);
  750. X          }
  751. X      }
  752. X***************
  753. X*** 383,389
  754. X          if (one_based) (appt->month)--;
  755. X          /* sanity check */
  756. X          if (appt->month < JAN || appt->month > DEC) {
  757. X-             /*
  758. X              sprintf(errbuf, "illegal month value [%d] (ignored)", appt->month);
  759. X              err_rpt(errbuf, NON_FATAL);
  760. X              */
  761. X
  762. X--- 419,424 -----
  763. X          if (one_based) (appt->month)--;
  764. X          /* sanity check */
  765. X          if (appt->month < JAN || appt->month > DEC) {
  766. X              sprintf(errbuf, "illegal month value [%d] (ignored)", appt->month);
  767. X              err_rpt(errbuf, NON_FATAL);
  768. X              return(1);
  769. X***************
  770. X*** 386,393
  771. X              /*
  772. X              sprintf(errbuf, "illegal month value [%d] (ignored)", appt->month);
  773. X              err_rpt(errbuf, NON_FATAL);
  774. X-             */
  775. X-             err_rpt("illegal month value (ignored)", NON_FATAL);
  776. X              return(1);
  777. X          }
  778. X      }
  779. X
  780. X--- 421,426 -----
  781. X          if (appt->month < JAN || appt->month > DEC) {
  782. X              sprintf(errbuf, "illegal month value [%d] (ignored)", appt->month);
  783. X              err_rpt(errbuf, NON_FATAL);
  784. X              return(1);
  785. X          }
  786. X      }
  787. X***************
  788. X*** 405,411
  789. X          if (!one_based) (appt->day)++;
  790. X          /* sanity check */
  791. X          if (appt->day < 1 || appt->day > 31) {
  792. X!             err_rpt("illegal day value (ignored)", NON_FATAL);
  793. X              return(1);
  794. X          }
  795. X      } else {
  796. X
  797. X--- 438,445 -----
  798. X          if (!one_based) (appt->day)++;
  799. X          /* sanity check */
  800. X          if (appt->day < 1 || appt->day > 31) {
  801. X!             sprintf(errbuf, "illegal day value [%d] (ignored)", appt->day);
  802. X!             err_rpt(errbuf, NON_FATAL);
  803. X              return(1);
  804. X          }
  805. X      } else {
  806. X***************
  807. X*** 431,437
  808. X              appt->flags |= EVERY_SAT;
  809. X          else {
  810. X              /* sanity check */
  811. X!             err_rpt("illegal day name (ignored)", NON_FATAL);
  812. X              return(1);
  813. X          }
  814. X          appt->day = 0;
  815. X
  816. X--- 465,472 -----
  817. X              appt->flags |= EVERY_SAT;
  818. X          else {
  819. X              /* sanity check */
  820. X!             sprintf(errbuf, "illegal day name [%s] (ignored)", wday);
  821. X!             err_rpt(errbuf, NON_FATAL);
  822. X              return(1);
  823. X          }
  824. X          appt->day = 0;
  825. X***************
  826. X*** 445,451
  827. X      appt->hour += *++ptr - '0';
  828. X      /* sanity check */
  829. X      if (appt->hour < 0 || (appt->hour > 23 && appt->hour != 99)) {
  830. X!         err_rpt("illegal hour value (ignored)", NON_FATAL);
  831. X          return(1);
  832. X      }
  833. X      if ((version2 && appt->hour == 99) || (!version2 && appt->hour == 0))
  834. X
  835. X--- 480,487 -----
  836. X      appt->hour += *++ptr - '0';
  837. X      /* sanity check */
  838. X      if (appt->hour < 0 || (appt->hour > 23 && appt->hour != 99)) {
  839. X!         sprintf(errbuf, "illegal hour value [%d] (ignored)", appt->hour);
  840. X!         err_rpt(errbuf, NON_FATAL);
  841. X          return(1);
  842. X      }
  843. X      if ((version2 && appt->hour == 99) || (!version2 && appt->hour == 0))
  844. X***************
  845. X*** 460,466
  846. X          /* minutes currently can only be 00 or 30
  847. X           * unless it's a note.
  848. X           */
  849. X!         err_rpt("illegal minute value (ignored)", NON_FATAL);
  850. X          return(1);
  851. X      }
  852. X      if ((appt->flags & A_NOTE) && version2 && appt->minute == 99)
  853. X
  854. X--- 496,503 -----
  855. X          /* minutes currently can only be 00 or 30
  856. X           * unless it's a note.
  857. X           */
  858. X!         sprintf(errbuf, "illegal minute value [%d] (ignored)", appt->minute);
  859. X!         err_rpt(errbuf, NON_FATAL);
  860. X          return(1);
  861. X      }
  862. X      if ((appt->flags & A_NOTE) && version2 && appt->minute == 99)
  863. X***************
  864. X*** 472,478
  865. X      appt->arrows += *++ptr - '0';
  866. X      /* sanity check */
  867. X      if (appt->arrows < 0 || appt->arrows > N_TSLOTS) {
  868. X!         err_rpt("illegal arrow value (ignored)", NON_FATAL);
  869. X          return(1);
  870. X      }
  871. X      ++ptr;
  872. X
  873. X--- 509,516 -----
  874. X      appt->arrows += *++ptr - '0';
  875. X      /* sanity check */
  876. X      if (appt->arrows < 0 || appt->arrows > N_TSLOTS) {
  877. X!         sprintf(errbuf, "illegal arrow value [%d] (ignored)", appt->arrows);
  878. X!         err_rpt(errbuf, NON_FATAL);
  879. X          return(1);
  880. X      }
  881. X      ++ptr;
  882. X***************
  883. X*** 480,513
  884. X          ++ptr;
  885. X      /* lookahead and repeat entries are free format, i.e. they */
  886. X      /* can occur in either order */
  887. X!     if (*ptr == '[') {
  888. X!         appt->flags |= REPEAT;
  889. X!         if (appt->flags & EVERY_SOMEDAY) {
  890. X!             if ((appt->repeat = do_wk_repeat(&ptr)) < 0)
  891. X!                 return(1);
  892. X!         } else {
  893. X!             if ((appt->repeat = do_repeat(&ptr)) < 0)
  894. X!                 return(1);
  895. X!         }
  896. X!         if (*ptr == '<') {
  897. X!             appt->flags |= LOOKAHEAD;
  898. X!             if ((appt->lookahead = do_lookahead(&ptr)) < 0)
  899. X!                 return(1);
  900. X!         }
  901. X!         if (*ptr == '#') {
  902. X!             appt->flags |= DELETED;
  903. X!             ++ptr;
  904. X!             while (isspace(*ptr))
  905. X!                 ++ptr;
  906. X!         }
  907. X!     } else if (*ptr == '<') {
  908. X!         appt->flags |= LOOKAHEAD;
  909. X!         if ((appt->lookahead = do_lookahead(&ptr)) < 0)
  910. X!             return(1);
  911. X!         if (*ptr == '[') {
  912. X!             appt->flags |= REPEAT;
  913. X!             if (appt->flags & EVERY_SOMEDAY) {
  914. X!                 if ((appt->repeat = do_wk_repeat(&ptr)) < 0)
  915. X                      return(1);
  916. X              } else {
  917. X                  if ((appt->repeat = do_repeat(&ptr)) < 0)
  918. X
  919. X--- 518,542 -----
  920. X          ++ptr;
  921. X      /* lookahead and repeat entries are free format, i.e. they */
  922. X      /* can occur in either order */
  923. X!     parse_options = TRUE;
  924. X!     while (parse_options) {
  925. X!         switch (*ptr) {
  926. X!             case '[':
  927. X!                 /* repeating appointment */
  928. X!                 appt->flags |= REPEAT;
  929. X!                 if (appt->flags & EVERY_SOMEDAY) {
  930. X!                     if ((appt->repeat = do_wk_repeat(&ptr)) < 0)
  931. X!                         return(1);
  932. X!                 } else {
  933. X!                     if ((appt->repeat = do_repeat(&ptr)) < 0)
  934. X!                         return(1);
  935. X!                 }
  936. X!                 break;
  937. X!             
  938. X!             case '<':
  939. X!                 /* remind us ahead of time */
  940. X!                 appt->flags |= LOOKAHEAD;
  941. X!                 if ((appt->lookahead = do_lookahead(&ptr)) < 0)
  942. X                      return(1);
  943. X                  break;
  944. X              
  945. X***************
  946. X*** 509,516
  947. X              if (appt->flags & EVERY_SOMEDAY) {
  948. X                  if ((appt->repeat = do_wk_repeat(&ptr)) < 0)
  949. X                      return(1);
  950. X!             } else {
  951. X!                 if ((appt->repeat = do_repeat(&ptr)) < 0)
  952. X                      return(1);
  953. X              }
  954. X          }
  955. X
  956. X--- 538,551 -----
  957. X                  appt->flags |= LOOKAHEAD;
  958. X                  if ((appt->lookahead = do_lookahead(&ptr)) < 0)
  959. X                      return(1);
  960. X!                 break;
  961. X!             
  962. X!             case '+':
  963. X!                 /* this appointment lasts for n days */
  964. X!                 appt->flags |= RUN;
  965. X!                 while (isdigit(*++ptr))
  966. X!                     appt->runlength = appt->runlength * 10 + (int)(*ptr - '0');
  967. X!                 if (appt->runlength < 0)
  968. X                      return(1);
  969. X                  if (!(appt->flags & REPEAT)) {
  970. X                      /* default to run of days */
  971. X***************
  972. X*** 512,523
  973. X              } else {
  974. X                  if ((appt->repeat = do_repeat(&ptr)) < 0)
  975. X                      return(1);
  976. X!             }
  977. X!         }
  978. X!         if (*ptr == '#') {
  979. X!             appt->flags |= DELETED;
  980. X!             ++ptr;
  981. X!             while (isspace(*ptr))
  982. X                  ++ptr;
  983. X          }
  984. X      } else if (*ptr == '#') {
  985. X
  986. X--- 547,562 -----
  987. X                      appt->runlength = appt->runlength * 10 + (int)(*ptr - '0');
  988. X                  if (appt->runlength < 0)
  989. X                      return(1);
  990. X!                 if (!(appt->flags & REPEAT)) {
  991. X!                     /* default to run of days */
  992. X!                     appt->flags |= REPEAT;
  993. X!                     appt->repeat = 1;
  994. X!                 }
  995. X!                 break;
  996. X! 
  997. X!             case '#':
  998. X!                 /* deleted appointment */
  999. X!                 appt->flags |= DELETED;
  1000. X                  ++ptr;
  1001. X                  break;
  1002. X              
  1003. X***************
  1004. X*** 519,524
  1005. X              ++ptr;
  1006. X              while (isspace(*ptr))
  1007. X                  ++ptr;
  1008. X          }
  1009. X      } else if (*ptr == '#') {
  1010. X          appt->flags |= DELETED;
  1011. X
  1012. X--- 558,568 -----
  1013. X                  /* deleted appointment */
  1014. X                  appt->flags |= DELETED;
  1015. X                  ++ptr;
  1016. X+                 break;
  1017. X+             
  1018. X+             default:
  1019. X+                 parse_options = FALSE;
  1020. X+                 break;
  1021. X          }
  1022. X          while (isspace(*ptr))
  1023. X              ++ptr;
  1024. X***************
  1025. X*** 520,528
  1026. X              while (isspace(*ptr))
  1027. X                  ++ptr;
  1028. X          }
  1029. X-     } else if (*ptr == '#') {
  1030. X-         appt->flags |= DELETED;
  1031. X-         ++ptr;
  1032. X          while (isspace(*ptr))
  1033. X              ++ptr;
  1034. X      }
  1035. X
  1036. X--- 564,569 -----
  1037. X                  parse_options = FALSE;
  1038. X                  break;
  1039. X          }
  1040. X          while (isspace(*ptr))
  1041. X              ++ptr;
  1042. X      }
  1043. X***************
  1044. X*** 553,560
  1045. X          return(-1);
  1046. X      }
  1047. X      ++*ptr;
  1048. X-     while (isspace(**ptr))
  1049. X-         ++*ptr;
  1050. X      return(repeat);
  1051. X  }
  1052. X  
  1053. X
  1054. X--- 594,599 -----
  1055. X          return(-1);
  1056. X      }
  1057. X      ++*ptr;
  1058. X      return(repeat);
  1059. X  }
  1060. X  
  1061. X***************
  1062. X*** 584,592
  1063. X          return(-1);
  1064. X      }
  1065. X      ++*ptr;
  1066. X-     while (isspace(**ptr))
  1067. X-         ++*ptr;
  1068. X- 
  1069. X      return(repeat);
  1070. X  }
  1071. X  
  1072. X
  1073. X--- 623,628 -----
  1074. X          return(-1);
  1075. X      }
  1076. X      ++*ptr;
  1077. X      return(repeat);
  1078. X  }
  1079. X  
  1080. X***************
  1081. X*** 608,615
  1082. X          return(-1);
  1083. X      }
  1084. X      ++*ptr;
  1085. X-     while (isspace(**ptr))
  1086. X-         ++*ptr;
  1087. X      return(lookahead);
  1088. X  }
  1089. X  
  1090. X
  1091. X--- 644,649 -----
  1092. X          return(-1);
  1093. X      }
  1094. X      ++*ptr;
  1095. X      return(lookahead);
  1096. X  }
  1097. X  
  1098. X***************
  1099. X*** 687,692
  1100. X  
  1101. X      if (appt->flags & LOOKAHEAD)
  1102. X          fprintf(apts_file, "<%d> ", appt->lookahead);
  1103. X      if (appt->flags & DELETED)
  1104. X          fprintf(apts_file, "# %s\n", appt->str);
  1105. X      else
  1106. X
  1107. X--- 721,728 -----
  1108. X  
  1109. X      if (appt->flags & LOOKAHEAD)
  1110. X          fprintf(apts_file, "<%d> ", appt->lookahead);
  1111. X+     if (appt->flags & RUN)
  1112. X+         fprintf(apts_file, "+%d ", appt->runlength);
  1113. X      if (appt->flags & DELETED)
  1114. X          fprintf(apts_file, "# %s\n", appt->str);
  1115. X      else
  1116. X***************
  1117. X*** 726,731
  1118. X      return (rptstr);
  1119. X  }
  1120. X  
  1121. X  /*
  1122. X   * Print today's appointments to stdout or mail (useful if we only have an ASCII
  1123. X   * terminal connected to our Sun). Invoked by the "-p", "-P" or "-m" options.
  1124. X
  1125. X--- 762,768 -----
  1126. X      return (rptstr);
  1127. X  }
  1128. X  
  1129. X+ #ifndef CALENCHECK
  1130. X  /*
  1131. X   * Print today's appointments to stdout or mail (useful if we only have an ASCII
  1132. X   * terminal connected to our Sun). Invoked by the "-p", "-P", "-m" or
  1133. X***************
  1134. X*** 728,734
  1135. X  
  1136. X  /*
  1137. X   * Print today's appointments to stdout or mail (useful if we only have an ASCII
  1138. X!  * terminal connected to our Sun). Invoked by the "-p", "-P" or "-m" options.
  1139. X   * Month information is only printed as PostScript output.
  1140. X   */
  1141. X  print_apts(which, dest)
  1142. X
  1143. X--- 765,772 -----
  1144. X  #ifndef CALENCHECK
  1145. X  /*
  1146. X   * Print today's appointments to stdout or mail (useful if we only have an ASCII
  1147. X!  * terminal connected to our Sun). Invoked by the "-p", "-P", "-m" or
  1148. X!  * "-M" options.
  1149. X   * Month information is only printed as PostScript output.
  1150. X   */
  1151. X  print_apts(which, dest)
  1152. X***************
  1153. X*** 734,740
  1154. X  print_apts(which, dest)
  1155. X  int which, dest;
  1156. X  {
  1157. X!     int i;
  1158. X      FILE *output, *pfp, *popen();
  1159. X      char cmd[80], *name, *cuserid();
  1160. X  
  1161. X
  1162. X--- 772,778 -----
  1163. X  print_apts(which, dest)
  1164. X  int which, dest;
  1165. X  {
  1166. X!     int i, gd_rtn;
  1167. X      FILE *output, *pfp, *popen();
  1168. X      char cmd[80], *name, *cuserid();
  1169. X  
  1170. X***************
  1171. X*** 738,746
  1172. X      FILE *output, *pfp, *popen();
  1173. X      char cmd[80], *name, *cuserid();
  1174. X  
  1175. X-     if (dest == DST_MAIL)
  1176. X-         /* only mail one day's appts */
  1177. X-         which = PRI_DAY;
  1178. X      fix_current_day();
  1179. X      if ((which == PRI_DAY) && !get_day_appts())
  1180. X          return;    /* nothing to show */
  1181. X
  1182. X--- 776,781 -----
  1183. X      FILE *output, *pfp, *popen();
  1184. X      char cmd[80], *name, *cuserid();
  1185. X  
  1186. X      fix_current_day();
  1187. X      gd_rtn = get_day_appts();
  1188. X      if (which == PRI_DAY && !gd_rtn)
  1189. X***************
  1190. X*** 742,748
  1191. X          /* only mail one day's appts */
  1192. X          which = PRI_DAY;
  1193. X      fix_current_day();
  1194. X!     if ((which == PRI_DAY) && !get_day_appts())
  1195. X          return;    /* nothing to show */
  1196. X      if (dest == DST_MAIL) {
  1197. X          if (mailto != NULL) {
  1198. X
  1199. X--- 777,784 -----
  1200. X      char cmd[80], *name, *cuserid();
  1201. X  
  1202. X      fix_current_day();
  1203. X!     gd_rtn = get_day_appts();
  1204. X!     if (which == PRI_DAY && !gd_rtn)
  1205. X          return;    /* nothing to show */
  1206. X      if (which == PRI_DAY_XNOTES && gd_rtn == SOME_MKNOTES)
  1207. X          /* all we have is marked notes */
  1208. X***************
  1209. X*** 744,749
  1210. X      fix_current_day();
  1211. X      if ((which == PRI_DAY) && !get_day_appts())
  1212. X          return;    /* nothing to show */
  1213. X      if (dest == DST_MAIL) {
  1214. X          if (mailto != NULL) {
  1215. X              name = mailto;
  1216. X
  1217. X--- 780,788 -----
  1218. X      gd_rtn = get_day_appts();
  1219. X      if (which == PRI_DAY && !gd_rtn)
  1220. X          return;    /* nothing to show */
  1221. X+     if (which == PRI_DAY_XNOTES && gd_rtn == SOME_MKNOTES)
  1222. X+         /* all we have is marked notes */
  1223. X+         return;    /* nothing to show */
  1224. X      if (dest == DST_MAIL) {
  1225. X          if (mailto != NULL) {
  1226. X              name = mailto;
  1227. X***************
  1228. X*** 750,756
  1229. X          } else if ((name = cuserid(NULL)) == NULL) {
  1230. X              err_rpt("nobody to mail to", FATAL);
  1231. X          }
  1232. X!         sprintf(cmd, "mail -s \"Appointments for today\" %s", name);
  1233. X          if ((output = popen(cmd, "w")) == NULL)
  1234. X              err_rpt("Couldn't pipe to 'mail'", FATAL);
  1235. X      } else {
  1236. X
  1237. X--- 789,795 -----
  1238. X          } else if ((name = cuserid(NULL)) == NULL) {
  1239. X              err_rpt("nobody to mail to", FATAL);
  1240. X          }
  1241. X!         sprintf(cmd, "%s -s \"Appointments for today\" %s", MAILPROG, name);
  1242. X          if ((output = popen(cmd, "w")) == NULL)
  1243. X              err_rpt("Couldn't pipe to 'mail'", FATAL);
  1244. X      } else {
  1245. X***************
  1246. X*** 758,764
  1247. X      }
  1248. X      
  1249. X      if (which == PRI_DAY || which == PRI_DAY_XNOTES) {
  1250. X!         print_one_day(which, output);
  1251. X      } else if (which == PRI_WEEK || which == PRI_WEEK_XNOTES) {
  1252. X          current.tm_mday -= current.tm_wday; /* Sunday of this week */
  1253. X          fix_current_day();
  1254. X
  1255. X--- 797,803 -----
  1256. X      }
  1257. X      
  1258. X      if (which == PRI_DAY || which == PRI_DAY_XNOTES) {
  1259. X!         print_one_day(which, output, gd_rtn);
  1260. X      } else if (which == PRI_WEEK || which == PRI_WEEK_XNOTES) {
  1261. X          current.tm_mday -= current.tm_wday; /* Sunday of this week */
  1262. X          fix_current_day();
  1263. X***************
  1264. X*** 762,768
  1265. X      } else if (which == PRI_WEEK || which == PRI_WEEK_XNOTES) {
  1266. X          current.tm_mday -= current.tm_wday; /* Sunday of this week */
  1267. X          fix_current_day();
  1268. X!         if (nr_weekdays < 7) {
  1269. X              current.tm_mday++;
  1270. X              fix_current_day();
  1271. X          }
  1272. X
  1273. X--- 801,807 -----
  1274. X      } else if (which == PRI_WEEK || which == PRI_WEEK_XNOTES) {
  1275. X          current.tm_mday -= current.tm_wday; /* Sunday of this week */
  1276. X          fix_current_day();
  1277. X!         if (nr_weekdays < 7 || monday_first) {
  1278. X              current.tm_mday++;
  1279. X              fix_current_day();
  1280. X          }
  1281. X***************
  1282. X*** 767,774
  1283. X              fix_current_day();
  1284. X          }
  1285. X          for (i=0;i<nr_weekdays;i++) {
  1286. X!             if (get_day_appts())
  1287. X!                 print_one_day(which, output);
  1288. X              current.tm_mday++;
  1289. X              fix_current_day();
  1290. X          }
  1291. X
  1292. X--- 806,814 -----
  1293. X              fix_current_day();
  1294. X          }
  1295. X          for (i=0;i<nr_weekdays;i++) {
  1296. X!             gd_rtn = get_day_appts();
  1297. X!             if ((gd_rtn && which == PRI_WEEK) || (gd_rtn & ~SOME_MKNOTES && which == PRI_WEEK_XNOTES))
  1298. X!                 print_one_day(which, output, gd_rtn);
  1299. X              current.tm_mday++;
  1300. X              fix_current_day();
  1301. X          }
  1302. X***************
  1303. X*** 780,786
  1304. X          pclose(output);
  1305. X  }
  1306. X  
  1307. X! print_one_day(which, output)
  1308. X  int which;
  1309. X  FILE *output;
  1310. X  {
  1311. X
  1312. X--- 820,826 -----
  1313. X          pclose(output);
  1314. X  }
  1315. X  
  1316. X! print_one_day(which, output, gdrtn)
  1317. X  int which;
  1318. X  FILE *output;
  1319. X  int gdrtn;
  1320. X***************
  1321. X*** 783,788
  1322. X  print_one_day(which, output)
  1323. X  int which;
  1324. X  FILE *output;
  1325. X  {
  1326. X      int i;
  1327. X      struct appt_entry tmp_apt;
  1328. X
  1329. X--- 823,829 -----
  1330. X  print_one_day(which, output, gdrtn)
  1331. X  int which;
  1332. X  FILE *output;
  1333. X+ int gdrtn;
  1334. X  {
  1335. X      int i;
  1336. X      struct appt_entry tmp_apt;
  1337. X***************
  1338. X*** 788,796
  1339. X      struct appt_entry tmp_apt;
  1340. X      char *format_appt();
  1341. X  
  1342. X!     fprintf(output,"\n\t*** Appointments for %s %s %d, %d ***\n\n", 
  1343. X!         daynames[current.tm_wday], monthnames[current.tm_mon],
  1344. X!         current.tm_mday, current.tm_year+1900);
  1345. X  
  1346. X      for (i=0; i<N_SLOTS; i++) {
  1347. X          if (i == n_tslots)
  1348. X
  1349. X--- 829,842 -----
  1350. X      struct appt_entry tmp_apt;
  1351. X      char *format_appt();
  1352. X  
  1353. X!     if (day_first)
  1354. X!         fprintf(output,"\n\t*** Appointments for %s %d %s %d ***\n\n", 
  1355. X!             daynames[current.tm_wday], current.tm_mday,
  1356. X!             monthnames[current.tm_mon], current.tm_year+1900);
  1357. X!     else
  1358. X!         fprintf(output,"\n\t*** Appointments for %s %s %d, %d ***\n\n", 
  1359. X!             daynames[current.tm_wday], monthnames[current.tm_mon],
  1360. X!             current.tm_mday, current.tm_year+1900);
  1361. X  
  1362. X      for (i=0; i<N_SLOTS; i++) {
  1363. X          if (i == n_tslots)
  1364. X***************
  1365. X*** 795,801
  1366. X      for (i=0; i<N_SLOTS; i++) {
  1367. X          if (i == n_tslots)
  1368. X              /* start of notes section */
  1369. X!             fprintf(output,"\n\t\t     ===== Notes =====\n");
  1370. X          if (slots[i].first != NULL && slots[i].count > 0) {
  1371. X              /* at least one appt here */
  1372. X              slots[i].cur_appt = slots[i].first;
  1373. X
  1374. X--- 841,849 -----
  1375. X      for (i=0; i<N_SLOTS; i++) {
  1376. X          if (i == n_tslots)
  1377. X              /* start of notes section */
  1378. X!             if ((gdrtn & SOME_NOTES) ||
  1379. X!                (!(which & PRI_XNOTES) && (gdrtn & SOME_MKNOTES)))
  1380. X!                 fprintf(output,"\n\t\t     ===== Notes =====\n");
  1381. X          if (slots[i].first != NULL && slots[i].count > 0) {
  1382. X              /* at least one appt here */
  1383. X              slots[i].cur_appt = slots[i].first;
  1384. X***************
  1385. X*** 841,847
  1386. X       * also support a "lookahead" reminder service to remind one
  1387. X       * in advance of a future appointment.
  1388. X       * If "save_old" is set, then any appointments for years prior
  1389. X!      * to this one are save in a special file of the form
  1390. X       * ".appointments.YY", where YY is the year.
  1391. X       */
  1392. X  
  1393. X
  1394. X--- 889,895 -----
  1395. X       * also support a "lookahead" reminder service to remind one
  1396. X       * in advance of a future appointment.
  1397. X       * If "save_old" is set, then any appointments for years prior
  1398. X!      * to this one are saved in a special file of the form
  1399. X       * ".appointments.YY", where YY is the year.
  1400. X       */
  1401. X  
  1402. X***************
  1403. X*** 864,870
  1404. X  
  1405. X       /* copy existing entries to the new file */
  1406. X       save_base = one_based;
  1407. X!      while ((err_flag = get_aentry(oappts, &appt)) != EOF) {
  1408. X          if (err_flag)
  1409. X              continue;    /* ignore badly formatted input */
  1410. X          if (appt.hour == 0)
  1411. X
  1412. X--- 912,918 -----
  1413. X  
  1414. X       /* copy existing entries to the new file */
  1415. X       save_base = one_based;
  1416. X!      while ((err_flag = get_aentry(oappts, &appt, TRUE)) != EOF) {
  1417. X          if (err_flag)
  1418. X              continue;    /* ignore badly formatted input */
  1419. X          if (appt.hour == 0)
  1420. X***************
  1421. X*** 891,898
  1422. X                  fclose(fp);
  1423. X              }
  1424. X          } else {
  1425. X!             if (put_aentry(nappts, &appt))
  1426. X!                 err_rpt("write to new appt file failed, bailing out", FATAL);
  1427. X          }
  1428. X          one_based = save_base;    /* (maybe) force old format input */
  1429. X      }
  1430. X
  1431. X--- 939,949 -----
  1432. X                  fclose(fp);
  1433. X              }
  1434. X          } else {
  1435. X!             if (appt.flags & A_COMMENT)
  1436. X!                 fputs(inbuf, nappts);
  1437. X!             else
  1438. X!                 if (put_aentry(nappts, &appt))
  1439. X!                     err_rpt("write to new appt file failed, bailing out", FATAL);
  1440. X          }
  1441. X          one_based = save_base;    /* (maybe) force old format input */
  1442. X      }
  1443. X***************
  1444. X*** 904,971
  1445. X  }
  1446. X  
  1447. X  /*
  1448. X-  * Scan appointments file for outdated appointments and save them to a
  1449. X-  * special file of the form ".appointments.YY", where YY is the year
  1450. X-  * of that appointment.
  1451. X-  */
  1452. X- create_old_files()
  1453. X- {
  1454. X-     FILE *oappts, *nappts, *fp;
  1455. X-     struct appt_entry appt;
  1456. X-     int err_flag;
  1457. X-     char save_file[128];
  1458. X-     struct stat stbuf;
  1459. X- 
  1460. X-     if (read_only != 0) {
  1461. X-         err_rpt("appts file is read-only, no conversion done", NON_FATAL);
  1462. X-         return;
  1463. X-     }
  1464. X- 
  1465. X-      /* open files, etc */
  1466. X-     if ((oappts = fopen(apts_pathname, "r")) == NULL) {
  1467. X-         err_rpt("can't open appts file for reading", FATAL);
  1468. X-         /* NOT REACHED */
  1469. X-      }
  1470. X-     if ((nappts = fopen(tmpapts_pathname, "w")) == NULL) {
  1471. X-         err_rpt("can't open temp file for writing", NON_FATAL);
  1472. X-         return;
  1473. X-      }
  1474. X- 
  1475. X-      /* copy existing entries to the tmp file, checking dates */
  1476. X-      while ((err_flag = get_aentry(oappts, &appt)) != EOF) {
  1477. X-         if (err_flag)
  1478. X-             continue;    /* ignore badly formatted input */
  1479. X-         if (!(appt.flags & A_COMMENT)
  1480. X-            && !(appt.flags & ALL_YEARS) && (appt.year < today.tm_year)
  1481. X-            && !((appt.flags & REPEAT) && !(appt.flags & EVERY_SOMEDAY))) {
  1482. X-             /* prepend directory info */
  1483. X-             sprintf(save_file, "%s/.appointments.%02d",
  1484. X-                 apts_dir, appt.year);
  1485. X-             if (stat(save_file, &stbuf) && errno == ENOENT) {
  1486. X-                 /* new file*/
  1487. X-                 if ((fp = fopen(save_file, "w")) == NULL)
  1488. X-                     err_rpt("can't open save file, bailing out", FATAL);
  1489. X-                 fputs(HEADER, fp);
  1490. X-                 fclose(fp);
  1491. X-             }
  1492. X-             if ((fp = fopen(save_file, "a+")) == NULL)
  1493. X-                 err_rpt("can't open save file, bailing out", FATAL);
  1494. X-             else {
  1495. X-                 if (put_aentry(fp, &appt))
  1496. X-                     err_rpt("write to save appt file failed, bailing out", FATAL);
  1497. X-                 fclose(fp);
  1498. X-             }
  1499. X-         } else {
  1500. X-             if (put_aentry(nappts, &appt))
  1501. X-                 err_rpt("write to new appt file failed, bailing out", FATAL);
  1502. X-         }
  1503. X-     }
  1504. X-     fclose(oappts);
  1505. X-     fclose(nappts);
  1506. X-     xrename(tmpapts_pathname, apts_pathname);
  1507. X- }
  1508. X- 
  1509. X- /*
  1510. X   * convert appt entry to ASCII string for display with date, time and msg
  1511. X   */
  1512. X  char *
  1513. X
  1514. X--- 955,960 -----
  1515. X  }
  1516. X  
  1517. X  /*
  1518. X   * convert appt entry to ASCII string for display with date, time and msg
  1519. X   */
  1520. X  char *
  1521. X***************
  1522. X*** 997,1005
  1523. X      if (appt->flags & A_NOTE) {
  1524. X          /* note */
  1525. X          if (appt->flags & ALL_YEARS)
  1526. X!             sprintf(strbuf,"%3.3s %2d/%02d    --  %s",
  1527. X!                 daynames[current.tm_wday], appt->month+1,
  1528. X!                 appt->day, appt->str);
  1529. X          else if (appt->year > 99)
  1530. X              sprintf(strbuf,"%3.3s %2d/%02d/%02d --  %s",
  1531. X                  daynames[current.tm_wday], appt->month+1,
  1532. X
  1533. X--- 986,999 -----
  1534. X      if (appt->flags & A_NOTE) {
  1535. X          /* note */
  1536. X          if (appt->flags & ALL_YEARS)
  1537. X!             if (day_first)
  1538. X!                 sprintf(strbuf,"%3.3s %2d/%02d    --  %s",
  1539. X!                     daynames[current.tm_wday], appt->day,
  1540. X!                     appt->month+1, appt->str);
  1541. X!             else
  1542. X!                 sprintf(strbuf,"%3.3s %2d/%02d    --  %s",
  1543. X!                     daynames[current.tm_wday], appt->month+1,
  1544. X!                     appt->day, appt->str);
  1545. X          else if (appt->year > 99)
  1546. X              if (day_first)
  1547. X                  sprintf(strbuf,"%3.3s %2d/%02d/%02d --  %s",
  1548. X***************
  1549. X*** 1001,1009
  1550. X                  daynames[current.tm_wday], appt->month+1,
  1551. X                  appt->day, appt->str);
  1552. X          else if (appt->year > 99)
  1553. X!             sprintf(strbuf,"%3.3s %2d/%02d/%02d --  %s",
  1554. X!                 daynames[current.tm_wday], appt->month+1,
  1555. X!                 appt->day, appt->year-100, appt->str);
  1556. X          else
  1557. X              sprintf(strbuf,"%3.3s %2d/%02d/%02d --  %s",
  1558. X                  daynames[current.tm_wday], appt->month+1,
  1559. X
  1560. X--- 995,1008 -----
  1561. X                      daynames[current.tm_wday], appt->month+1,
  1562. X                      appt->day, appt->str);
  1563. X          else if (appt->year > 99)
  1564. X!             if (day_first)
  1565. X!                 sprintf(strbuf,"%3.3s %2d/%02d/%02d --  %s",
  1566. X!                     daynames[current.tm_wday], appt->day,
  1567. X!                     appt->month+1, appt->year-100, appt->str);
  1568. X!             else
  1569. X!                 sprintf(strbuf,"%3.3s %2d/%02d/%02d --  %s",
  1570. X!                     daynames[current.tm_wday], appt->month+1,
  1571. X!                     appt->day, appt->year-100, appt->str);
  1572. X          else
  1573. X              if (day_first)
  1574. X                  sprintf(strbuf,"%3.3s %2d/%02d/%02d --  %s",
  1575. X***************
  1576. X*** 1005,1014
  1577. X                  daynames[current.tm_wday], appt->month+1,
  1578. X                  appt->day, appt->year-100, appt->str);
  1579. X          else
  1580. X!             sprintf(strbuf,"%3.3s %2d/%02d/%02d --  %s",
  1581. X!                 daynames[current.tm_wday], appt->month+1,
  1582. X!                 appt->day, appt->year, appt->str);
  1583. X!     } else
  1584. X          /* standard appointment */
  1585. X          sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %2d:%02d to %2d:%02d   %s",
  1586. X              daynames[current.tm_wday], appt->month+1,
  1587. X
  1588. X--- 1004,1018 -----
  1589. X                      daynames[current.tm_wday], appt->month+1,
  1590. X                      appt->day, appt->year-100, appt->str);
  1591. X          else
  1592. X!             if (day_first)
  1593. X!                 sprintf(strbuf,"%3.3s %2d/%02d/%02d --  %s",
  1594. X!                     daynames[current.tm_wday], appt->day,
  1595. X!                     appt->month+1, appt->year, appt->str);
  1596. X!             else
  1597. X!                 sprintf(strbuf,"%3.3s %2d/%02d/%02d --  %s",
  1598. X!                     daynames[current.tm_wday], appt->month+1,
  1599. X!                     appt->day, appt->year, appt->str);
  1600. X!     } else {
  1601. X          /* standard appointment */
  1602. X          if (hour24)
  1603. X              if (day_first)
  1604. X***************
  1605. X*** 1010,1020
  1606. X                  appt->day, appt->year, appt->str);
  1607. X      } else
  1608. X          /* standard appointment */
  1609. X!         sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %2d:%02d to %2d:%02d   %s",
  1610. X!             daynames[current.tm_wday], appt->month+1,
  1611. X!             appt->day, appt->year, appt->hour, appt->minute,
  1612. X!             e_hour, e_minutes, appt->str);
  1613. X! 
  1614. X      current = Save;
  1615. X      return(strbuf);
  1616. X  }
  1617. X
  1618. X--- 1014,1048 -----
  1619. X                      appt->day, appt->year, appt->str);
  1620. X      } else {
  1621. X          /* standard appointment */
  1622. X!         if (hour24)
  1623. X!             if (day_first)
  1624. X!                 sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %2d:%02d to %2d:%02d   %s",
  1625. X!                     daynames[current.tm_wday], appt->day,
  1626. X!                     appt->month+1, appt->year, appt->hour, appt->minute,
  1627. X!                     e_hour, e_minutes, appt->str);
  1628. X!             else
  1629. X!                 sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %2d:%02d to %2d:%02d   %s",
  1630. X!                     daynames[current.tm_wday], appt->month+1,
  1631. X!                     appt->day, appt->year, appt->hour, appt->minute,
  1632. X!                     e_hour, e_minutes, appt->str);
  1633. X!         else
  1634. X!             if (day_first)
  1635. X!                 sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %2d:%02d%s to %2d:%02d%s   %s",
  1636. X!                     daynames[current.tm_wday], appt->day,
  1637. X!                     appt->month+1, appt->year, (appt->hour < 13 ? appt->hour : appt->hour-12), appt->minute,
  1638. X!                     (appt->hour < 12 ? "am" : "pm"),
  1639. X!                     (e_hour < 13 ? e_hour : e_hour-12), e_minutes,
  1640. X!                     (e_hour < 12 ? "am" : "pm"),
  1641. X!                     appt->str);
  1642. X!             else
  1643. X!                 sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %2d:%02d%s to %2d:%02d%s   %s",
  1644. X!                     daynames[current.tm_wday], appt->month+1,
  1645. X!                     appt->day, appt->year, (appt->hour < 13 ? appt->hour : appt->hour-12), appt->minute,
  1646. X!                     (appt->hour < 12 ? "am" : "pm"),
  1647. X!                     (e_hour < 13 ? e_hour : e_hour-12), e_minutes,
  1648. X!                     (e_hour < 12 ? "am" : "pm"),
  1649. X!                     appt->str);
  1650. X!     }
  1651. X      current = Save;
  1652. X      return(strbuf);
  1653. X  }
  1654. X***************
  1655. X*** 1046,1052
  1656. X      }
  1657. X  
  1658. X      strbuf[0] = '\0';
  1659. X!     if (!(appt->flags & A_NOTE))
  1660. X          /* standard appointment */
  1661. X          sprintf(strbuf,"%2d:%02d to %2d:%02d  ",
  1662. X              appt->hour, appt->minute, e_hour, e_minutes);
  1663. X
  1664. X--- 1074,1080 -----
  1665. X      }
  1666. X  
  1667. X      strbuf[0] = '\0';
  1668. X!     if (!(appt->flags & A_NOTE)) {
  1669. X          /* standard appointment */
  1670. X          if (hour24)
  1671. X              sprintf(strbuf,"%2d:%02d to %2d:%02d  ",
  1672. X***************
  1673. X*** 1048,1055
  1674. X      strbuf[0] = '\0';
  1675. X      if (!(appt->flags & A_NOTE))
  1676. X          /* standard appointment */
  1677. X!         sprintf(strbuf,"%2d:%02d to %2d:%02d  ",
  1678. X!             appt->hour, appt->minute, e_hour, e_minutes);
  1679. X      p = appt->str;
  1680. X      q = strbuf + strlen(strbuf);
  1681. X      while (*p) {
  1682. X
  1683. X--- 1076,1091 -----
  1684. X      strbuf[0] = '\0';
  1685. X      if (!(appt->flags & A_NOTE)) {
  1686. X          /* standard appointment */
  1687. X!         if (hour24)
  1688. X!             sprintf(strbuf,"%2d:%02d to %2d:%02d  ",
  1689. X!                 appt->hour, appt->minute, e_hour, e_minutes);
  1690. X!         else
  1691. X!             sprintf(strbuf,"%2d:%02d%s to %2d:%02d%s  ",
  1692. X!                 (appt->hour < 13 ? appt->hour : appt->hour-12), appt->minute,
  1693. X!                 (appt->hour < 12 ? "am" : "pm"),
  1694. X!                 (e_hour < 13 ? e_hour : e_hour-12), e_minutes,
  1695. X!                 (e_hour < 12 ? "am" : "pm"));
  1696. X!     }
  1697. X      p = appt->str;
  1698. X      q = strbuf + strlen(strbuf);
  1699. X      while (*p) {
  1700. X***************
  1701. X*** 1077,1083
  1702. X  }
  1703. X  
  1704. X  /*
  1705. X!  * parse the date on the given tring and reset the "current"
  1706. X   * date to reflect that date. The date may take the form of a
  1707. X   * day name (e.g. Tu, Tue, Tuesday) or a date in m/d/y format
  1708. X   * where the month and/or year may be missing (e.g. 27 = 27th
  1709. X
  1710. X--- 1113,1119 -----
  1711. X  }
  1712. X  
  1713. X  /*
  1714. X!  * parse the date on the given string and reset the "current"
  1715. X   * date to reflect that date. The date may take the form of a
  1716. X   * day name (e.g. Tu, Tue, Tuesday) or a date in m/d/y format
  1717. X   * where the month and/or year may be missing (e.g. 27 = 27th
  1718. X***************
  1719. X*** 1084,1089
  1720. X   * of this month, 8/27 = August 27 of this year, 8/27/89 =
  1721. X   * August 27 of 1989. If 'cmdline' is true, then the string
  1722. X   * came from the command line '-d' option.
  1723. X   */
  1724. X  int
  1725. X  parse_date(str, cmdline)
  1726. X
  1727. X--- 1120,1128 -----
  1728. X   * of this month, 8/27 = August 27 of this year, 8/27/89 =
  1729. X   * August 27 of 1989. If 'cmdline' is true, then the string
  1730. X   * came from the command line '-d' option.
  1731. X+  * If the first character of the date is + or - scan the number and
  1732. X+  * use it as an offset in days from the current date.  Thus -1 becomes
  1733. X+  * yesterday and +1 becomes tomorrow. pbm.
  1734. X   */
  1735. X  int
  1736. X  parse_date(str, cmdline)
  1737. X***************
  1738. X*** 1125,1134
  1739. X          }
  1740. X          if (y > 0)
  1741. X              current.tm_year = y;
  1742. X!         if (m > 0)
  1743. X!             current.tm_mon = m - 1;
  1744. X!         if (d > 0)
  1745. X!             current.tm_mday = d;
  1746. X          fix_current_day();
  1747. X      } else {
  1748. X          /* day of week */
  1749. X
  1750. X--- 1164,1182 -----
  1751. X          }
  1752. X          if (y > 0)
  1753. X              current.tm_year = y;
  1754. X!         if (day_first) {
  1755. X!             if (m > 0) {
  1756. X!                 current.tm_mon = d - 1;
  1757. X!                 current.tm_mday = m;
  1758. X!             } else if (d > 0)
  1759. X!                 current.tm_mday = d;
  1760. X!         } else {
  1761. X!             if (m > 0) {
  1762. X!                 current.tm_mon = m - 1;
  1763. X!                 current.tm_mday = d;
  1764. X!             } else if (d > 0)
  1765. X!                 current.tm_mday = d;
  1766. X!         }
  1767. X          fix_current_day();
  1768. X      } else if (*str == '-' || *str == '+') {
  1769. X          /*
  1770. X***************
  1771. X*** 1130,1135
  1772. X          if (d > 0)
  1773. X              current.tm_mday = d;
  1774. X          fix_current_day();
  1775. X      } else {
  1776. X          /* day of week */
  1777. X          /* check for day names */
  1778. X
  1779. X--- 1178,1193 -----
  1780. X                  current.tm_mday = d;
  1781. X          }
  1782. X          fix_current_day();
  1783. X+     } else if (*str == '-' || *str == '+') {
  1784. X+         /*
  1785. X+          * If the argument begins with a + or - assume that it is an
  1786. X+          * offset in days from the current date. Use current date if the
  1787. X+          * number doesn't scan after the - or +. pbm
  1788. X+          */
  1789. X+         if (sscanf(str, "%d", &i) == 1) {
  1790. X+             current.tm_mday += i;
  1791. X+             fix_current_day();
  1792. X+         }
  1793. X      } else {
  1794. X          /* day of week */
  1795. X          /* check for day names */
  1796. X***************
  1797. X*** 1180,1186
  1798. X  
  1799. X      lock_cursors();
  1800. X      working(TRUE);
  1801. X!     sprintf(buf, "Appointments file \"%s\" printed for %s on %s", apts_pathname, cuserid(NULL), todays_date);
  1802. X      if (mainsw_state != DISPLAYING_MONTH) {
  1803. X          if ((fp = fopen(rasfile, "w")) != NULL) {
  1804. X              rect = (Rect *) window_get(canvas, WIN_RECT);
  1805. X
  1806. X--- 1238,1244 -----
  1807. X  
  1808. X      lock_cursors();
  1809. X      working(TRUE);
  1810. X!     sprintf(buf, "Appointments file \"%s\" printed for %s on %s", apts_pathname, cuserid(NULL), clockstr);
  1811. X      if (mainsw_state != DISPLAYING_MONTH) {
  1812. X          if ((fp = fopen(rasfile, "w")) != NULL) {
  1813. X              rect = (Rect *) window_get(canvas, WIN_RECT);
  1814. X***************
  1815. X*** 1217,1223
  1816. X              err_rpt("only PostScript output available for month printout", NON_FATAL);
  1817. X          } else {
  1818. X              if ((pfp = fopen(psfile, "w")) != NULL) {
  1819. X!                 print_month(pfp, FALSE);
  1820. X                  fclose(pfp);
  1821. X                  sprintf(prntcmd, "%s %s", printer, psfile);
  1822. X                  system(prntcmd);
  1823. X
  1824. X--- 1275,1281 -----
  1825. X              err_rpt("only PostScript output available for month printout", NON_FATAL);
  1826. X          } else {
  1827. X              if ((pfp = fopen(psfile, "w")) != NULL) {
  1828. X!                 print_month(pfp, TRUE);
  1829. X                  fclose(pfp);
  1830. X                  sprintf(prntcmd, "%s %s", printer, psfile);
  1831. X                  system(prntcmd);
  1832. X***************
  1833. X*** 1230,1235
  1834. X      unlock_cursors();
  1835. X  }
  1836. X  #endif    /* NO_PRINTER */
  1837. X  
  1838. X  /* set error logging flag */
  1839. X  err2console(state)
  1840. X
  1841. X--- 1288,1294 -----
  1842. X      unlock_cursors();
  1843. X  }
  1844. X  #endif    /* NO_PRINTER */
  1845. X+ #endif  /* CALENCHECK */
  1846. X  
  1847. X  /* set error logging flag */
  1848. X  err2console(state)
  1849. X***************
  1850. X*** 1252,1257
  1851. X  {
  1852. X      FILE    *f;
  1853. X      int    closed;
  1854. X  
  1855. X      closed = (int) window_get(frame, FRAME_CLOSED);
  1856. X      if (frame && !log_to_console && !closed) {
  1857. X
  1858. X--- 1311,1317 -----
  1859. X  {
  1860. X      FILE    *f;
  1861. X      int    closed;
  1862. X+     char *getenv();
  1863. X  
  1864. X  #ifndef NOTOOL
  1865. X      closed = (int) window_get(frame, FRAME_CLOSED);
  1866. X***************
  1867. X*** 1253,1258
  1868. X      FILE    *f;
  1869. X      int    closed;
  1870. X  
  1871. X      closed = (int) window_get(frame, FRAME_CLOSED);
  1872. X      if (frame && !log_to_console && !closed) {
  1873. X          /* base frame exists */
  1874. X
  1875. X--- 1313,1319 -----
  1876. X      int    closed;
  1877. X      char *getenv();
  1878. X  
  1879. X+ #ifndef NOTOOL
  1880. X      closed = (int) window_get(frame, FRAME_CLOSED);
  1881. X      if (frame && !log_to_console && !closed) {
  1882. X          /* base frame exists */
  1883. X***************
  1884. X*** 1260,1265
  1885. X          (void) window_loop(prompt_frame);
  1886. X          window_set(prompt_frame, WIN_SHOW, FALSE, 0);
  1887. X      } else if ((f=fopen("/dev/console", "w")) != NULL) {
  1888. X          fprintf(f, "%s: %s\n", progname, errstr);
  1889. X          fclose(f);
  1890. X      } else
  1891. X
  1892. X--- 1321,1329 -----
  1893. X          (void) window_loop(prompt_frame);
  1894. X          window_set(prompt_frame, WIN_SHOW, FALSE, 0);
  1895. X      } else if ((f=fopen("/dev/console", "w")) != NULL) {
  1896. X+ #else
  1897. X+     if (getenv("WINDOW_PARENT") != NULL && (f=fopen("/dev/console", "w")) != NULL) {
  1898. X+ #endif
  1899. X          fprintf(f, "%s: %s\n", progname, errstr);
  1900. X          fclose(f);
  1901. X      } else
  1902. X***************
  1903. X*** 1268,1273
  1904. X          exit(1);
  1905. X  }
  1906. X  
  1907. X  /* Clean-up */
  1908. X  cleanup()
  1909. X  {
  1910. X
  1911. X--- 1332,1338 -----
  1912. X          exit(1);
  1913. X  }
  1914. X  
  1915. X+ #ifndef CALENCHECK
  1916. X  /* Clean-up */
  1917. X  cleanup()
  1918. X  {
  1919. X***************
  1920. X*** 1275,1282
  1921. X          close_day();
  1922. X  
  1923. X      /* create outdated include files (if necessary) */
  1924. X!     if (save_old)
  1925. X!         create_old_files();
  1926. X              
  1927. X      /* delete tmp file */
  1928. X      if (access(tmpapts_pathname, R_OK) == 0 && unlink(tmpapts_pathname) < 0)
  1929. X
  1930. X--- 1340,1347 -----
  1931. X          close_day();
  1932. X  
  1933. X      /* create outdated include files (if necessary) */
  1934. X!     if (save_old || expire_days)
  1935. X!         expire(expire_days);
  1936. X              
  1937. X      /* delete tmp file */
  1938. X      if (access(tmpapts_pathname, R_OK) == 0 && unlink(tmpapts_pathname) < 0)
  1939. X***************
  1940. X*** 1296,1298
  1941. X              err_rpt("couldn't rename/copy tmp file", NON_FATAL);
  1942. X      }
  1943. X  }
  1944. X
  1945. X--- 1361,1364 -----
  1946. X              err_rpt("couldn't rename/copy tmp file", NON_FATAL);
  1947. X      }
  1948. X  }
  1949. X+ #endif  /* CALENCHECK */
  1950. X*** /tmp/,RCSt1a16998    Fri Dec 15 17:24:01 1989
  1951. X--- version.c    Fri Dec 15 17:18:34 1989
  1952. X***************
  1953. X*** 1,5
  1954. X  /*
  1955. X!  * $Header: version.c,v 2.5 89/09/19 06:09:07 billr Exp $
  1956. X   */
  1957. X  /*
  1958. X   * version.c - current version of calentool program
  1959. X
  1960. X--- 1,5 -----
  1961. X  /*
  1962. X!  * $Header: version.c,v 2.6 89/12/15 17:18:32 billr Exp $
  1963. X   */
  1964. X  /*
  1965. X   * version.c - current version of calentool program
  1966. X***************
  1967. X*** 24,27
  1968. X   * notice remains intact.
  1969. X   */
  1970. X  
  1971. X! char version[] = "Calendar Tool V2.1p4";
  1972. X
  1973. X--- 24,27 -----
  1974. X   * notice remains intact.
  1975. X   */
  1976. X  
  1977. X! char version[] = "Calendar Tool V2.1p5";
  1978. X*** /tmp/,RCSt1a17003    Fri Dec 15 17:24:04 1989
  1979. X--- wevent.c    Fri Dec 15 17:18:37 1989
  1980. X***************
  1981. X*** 1,5
  1982. X  /*
  1983. X!  * $Header: wevent.c,v 2.1 89/05/09 14:19:57 billr Exp $
  1984. X   */
  1985. X  /*
  1986. X   * wevent.c
  1987. X
  1988. X--- 1,5 -----
  1989. X  /*
  1990. X!  * $Header: wevent.c,v 2.2 89/12/15 17:18:35 billr Exp $
  1991. X   */
  1992. X  /*
  1993. X   * wevent.c
  1994. X***************
  1995. X*** 36,41
  1996. X  #include "event.h"
  1997. X  
  1998. X  extern Frame prompt_frame;
  1999. X  
  2000. X  week_inputevent(canvas, event) 
  2001. X  Canvas canvas;
  2002. X
  2003. X--- 36,42 -----
  2004. X  #include "event.h"
  2005. X  
  2006. X  extern Frame prompt_frame;
  2007. X+ extern int monday_first;
  2008. X  
  2009. X  week_inputevent(canvas, event) 
  2010. X  Canvas canvas;
  2011. X***************
  2012. X*** 84,89
  2013. X              return;
  2014. X          }
  2015. X          current.tm_mday -= current.tm_wday;
  2016. X          current.tm_mday += day_chosen_from_week;
  2017. X          fix_current_day();
  2018. X          if (nr_weekdays == 5) {
  2019. X
  2020. X--- 85,96 -----
  2021. X              return;
  2022. X          }
  2023. X          current.tm_mday -= current.tm_wday;
  2024. X+         if (monday_first) {
  2025. X+             if (current.tm_wday == SUN)
  2026. X+                 current.tm_mday -= 7;
  2027. X+             if (nr_weekdays == 7)
  2028. X+                 current.tm_mday++;
  2029. X+         }
  2030. X          current.tm_mday += day_chosen_from_week;
  2031. X          fix_current_day();
  2032. X          if (nr_weekdays < 7) {
  2033. X***************
  2034. X*** 86,92
  2035. X          current.tm_mday -= current.tm_wday;
  2036. X          current.tm_mday += day_chosen_from_week;
  2037. X          fix_current_day();
  2038. X!         if (nr_weekdays == 5) {
  2039. X              current.tm_mday++;
  2040. X              fix_current_day();
  2041. X          }
  2042. X
  2043. X--- 93,99 -----
  2044. X          }
  2045. X          current.tm_mday += day_chosen_from_week;
  2046. X          fix_current_day();
  2047. X!         if (nr_weekdays < 7) {
  2048. X              current.tm_mday++;
  2049. X              fix_current_day();
  2050. X          }
  2051. END_OF_FILE
  2052. if test 51460 -ne `wc -c <'patches05d'`; then
  2053.     echo shar: \"'patches05d'\" unpacked with wrong size!
  2054. fi
  2055. # end of 'patches05d'
  2056. fi
  2057. echo shar: End of archive 4 \(of 4\).
  2058. cp /dev/null ark4isdone
  2059. MISSING=""
  2060. for I in 1 2 3 4 ; do
  2061.     if test ! -f ark${I}isdone ; then
  2062.     MISSING="${MISSING} ${I}"
  2063.     fi
  2064. done
  2065. if test "${MISSING}" = "" ; then
  2066.     echo You have unpacked all 4 archives.
  2067.     rm -f ark[1-9]isdone
  2068. else
  2069.     echo You still need to unpack the following archives:
  2070.     echo "        " ${MISSING}
  2071. fi
  2072. ##  End of shell archive.
  2073. exit 0
  2074.  
  2075.